<?php
class VipController extends Controller
{
	
	public $layout='//layouts/vip_layout';
	
	
	public function filters()
	{
		return array(
				'accessControl', // perform access control for CRUD operations
				'postOnly + delete', // we only allow deletion via POST request
		);
	}
	
	public function accessRules()
	{
		return array(
				array('allow',  // allow all users to perform 'index' and 'view' actions
						'actions'=>array('index','view','Categories'),
						'users'=>array('*'),
				),
				array('allow', // allow authenticated user to perform 'create' and 'update' actions
						'actions'=>array('zone','shoe'),
						'users'=>array('@'),
				),
				array('allow', // allow admin user to perform 'admin' and 'delete' actions
						'actions'=>array('admin','delete'),
						'users'=>array('admin'),
				),
				array('deny',  // deny all users
						'users'=>array('*'),
				),
		);
	}
	
	
	public function actionZone(){
		$this->render('zone');	
	}
	
	
	public function actionShoe()
	{
		
		
		$dataProvider=new CActiveDataProvider('Shoe',
				array('criteria' => array(
						'select'    => "*",
						'condition'=> "item_permissionlv in (". Yii::app()->user->role .")",
				),
						'pagination' => array(
								'pageSize'=>6,
						),
				));
	
		$this->render('shoeindex',array(
				'dataProvider'=>$dataProvider,
		));
	}
	
	
	public function actionCategories($style)
	{
		$aa=Categories::model()->getChild($style);
	
		$list = CHtml::listData($aa,'id','id');
	
		$cc = $style;
		foreach ($list as $v)
			$cc .= ','.$v;
	
		$dataProvider=new CActiveDataProvider('Shoe',
				array('criteria' => array(
						'select'    => "*",
						'condition'=> "item_permissionlv <= :keyword01 and item_parent in ( ".$cc." )",
						'params'    => array(':keyword01' => "1"),
				),
						'pagination' => array(
								'pageSize'=>6,
						),
				));
		//var_dump($dataProvider);
		$this->render('style',array(
				'dataProvider'=>$dataProvider,
		));
	}
	
}